import {createRouter, createWebHistory} from 'vue-router'

import {createRouterGuards} from './guard.ts';

import BaseRouters from './routers.ts';


import {appStoreWidthOut} from "@/stores/app.ts";

//处理路由
export const handelRoutes =async () => {
  const appStore=appStoreWidthOut()
  const routes = await appStore.generateRoutes();
  return [...BaseRouters,...routes];
}


export const setupRouter = async () => {
  const routesArray =await handelRoutes();
  const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: routesArray,
    strict: true,
  });
  createRouterGuards(router);
  return router;
}

